import emitter from 'tiny-emitter/instance'

export default {
  $on: (...args: any) => emitter.on(...args),
  $once: (...args: any) => emitter.once(...args),
  $off: (...args: [any]) => {
    const [names] = args
    if (Array.isArray(names)) {
      names.forEach((name) => emitter.off(name))
    } else {
      emitter.off(names)
    }
  },
  $emit: (...args: any) => emitter.emit(...args),
}
